package com.xxx.dto;

import java.io.Serializable;

/**
 * 接口返回基类（不带业务数据）
 * 
 * 
 * 
 */
public class BaseDTO implements Serializable {

	private static final long serialVersionUID = -2856340853993127841L;

	public static final int SUCCESS = 200; 		// 成功
	public static final int FAILD = 100;		// 失败
	public static final int NOT_LOGON = 401;	// 未登录
	public static final int NEED_VERIFY = 403;	// 未通过交易密码和短信验证码
	public static final int NEED_CREDENT = 404;	// 未通过身份认证
	public static final int EXCEPTION = 500;	// 异常
	
	public static final String SUCCESS_MSG = "success"; 	// 成功
	public static final String FAILD_MSG = "fail";			// 失败
	public static final String EXCEPTION_MSG = "exception";	// 异常

	private int code;
	private String msg;

	public BaseDTO(int code, String msg) {
		this.code = code;
		this.msg = msg;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public static BaseDTO builtSuccess() {
		return new BaseDTO(SUCCESS, SUCCESS_MSG);
	}

	public static BaseDTO builtFail(String msg) {
		return new BaseDTO(FAILD, msg);
	}

	public static BaseDTO builtFail(int code, String msg) {
		return new BaseDTO(code, msg);
	}

	public static ResponseDTO builtException() {
		return new ResponseDTO(EXCEPTION, EXCEPTION_MSG, null);
	}

}
